package com.edu.user.config;


import com.edu.user.intcep.LoginInterceptor;
import com.edu.user.intcep.RefreshTokenInterceptor;
import jakarta.annotation.Resource;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;


@Configuration
public class MvcConfig implements WebMvcConfigurer {
    @Resource
    private StringRedisTemplate stringRedisTemplate;
    @Override
    public void addInterceptors(InterceptorRegistry registry) {

        //登录拦截器
        registry.addInterceptor(new LoginInterceptor())
                .excludePathPatterns(
                 /*     "/user/login/**",
                        "/diseases/**",
                        "/doctors/all",
                          "/doctors/{doctorId}",
                          "/doctors/schedules/{doctorId}",
                          "/doctors/department"*/
                        "/**"

                ).order(1);
            //   order为设置优先级，0的优先级更高
        //token刷新的拦截器
        registry.addInterceptor(new RefreshTokenInterceptor(stringRedisTemplate)).addPathPatterns("/**").order(0);
    }
}
